﻿<html>
<head>
<title>MÁY IN</title>
<style type="text/css">
body {
    background: #c7c8ff url("http://aimg.disneystore.com/content/ds/skyway/2012/category/rails/cp_RAL_SleepingBeauty_20120926.gif") no-repeat fixed top left;
    color:#001070 ;
    text-align:center;
    }
#mi
{
	background: #5054fe;
    margin: 0 auto;
    width: 264px;
    height: 50px;
    border-bottom: 2px groove #6266ff;
}
#vien{
    border:2px groove #6266ff;
    width: 264px;
    height: auto;
    
}
table{
    background:#8184ff;
}
.line {
    background:#5054fe;
    border:2px solid #6266ff;
    color: #001070;
    font-weight: bold;
    margin: 5px;
}
.nut{
    background-color:#4d90f0;
    border: 1px solid #3079ed;
    color: #fff;
    font-weight: bold;
    margin: 5px;
}
.nut:hover{
    background:red;
}
</style>
</head>
<body>
<form method="POST" action="">
<center>
<div id="vien">
 <h1 id="mi"><font color=#001070> MÁY IN</font></h1>
<Table align=center>
	<tr>
		<td>
			Trọng lượng:
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="trongluong" SIZE="10">
		</td>
	</tr>
	<tr>
		<td>
			Năm SX: 
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="namsx" SIZE="10">
		</td>
		<td>
		(YYYY)
		</td>
	</tr>
	<tr>
		<td>
			Hãng SX: 
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="hangsx" SIZE="10">
		</td>
	</tr>
	<tr>
		<td colspan=3 align=center font=bold>
		<div class="line"><b>MÁY IN KIM</b></div>	
		</td>
	</tr>
	<tr>
		<td>
			Số kim:
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="sokim" SIZE="10">
		</td>
	</tr>
	<tr>
		<td>
			Tốc độ in:
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="tocdoin" SIZE="10">
		</td>
		<td>
		(trang/ phút)
		</td>
	</tr>
	<tr>
		<td colspan=3 align=center>
			<div class="line"><b>MÁY IN LASER</b></div>
		</td>
	</tr>
	<tr>
		<td>
			Độ phân giải:
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="dophangiai" SIZE="10">
		</td>
	</tr>
	<tr>
		<td>
			Tốc độ in:
		</td>
		<td>
			<INPUT  TYPE= "text" NAME ="tocdoin2" SIZE="10">
		</td>
		<td>
		(trang/ phút)
		</td>
	</tr>
	<tr>
        <td align=right>
			<input type="submit" class="nut" name="text" value="Xem">
        </td>
		<td align=center>
			<input type="reset" class="nut" name="text" value= " Xóa ">
		</td>
	</tr>
</table>
</div>
</center>
<?php
		if(isset($_POST["trongluong"])&&isset($_POST["namsx"])&&isset($_POST["hangsx"])&&isset($_POST["sokim"])&&isset($_POST["tocdoin"])&&isset($_POST["dophangiai"])&&isset($_POST["tocdoin2"]))
		{
			$trongluong=$_POST["trongluong"];
			$namsx=$_POST["namsx"];
			$hangsx=$_POST["hangsx"];
			$sokim=(int)$_POST["sokim"];
			$tocdoin=(int)$_POST["tocdoin"];
			$dophangiai=(int)$_POST["dophangiai"];
			$tocdoin2=(int)$_POST["tocdoin2"];
			$tl=is_numeric($trongluong);
			$nam=is_numeric($namsx);
			$kim=is_numeric($sokim);
			$tocdo=is_numeric($tocdoin);
			$phangiai=is_numeric($dophangiai);
			$tocdo2=is_numeric($tocdoin2);
			if($trongluong==null||$namsx==null||$hangsx==null||$sokim==null||$tocdoin==null||$dophangiai==null||$tocdoin2==null||$tl!=1)
			{
				echo"<h1><b> :(</b><br> Giá trị bạn nhập vào không đúng!</h1> ";
				return;
			}
			elseif(strlen($namsx)!=4||$nam!=1)
			{
				echo "<h1><b> :(</b><br>Sai định dạng năm</h1>";
				return;
			}
			elseif($trongluong<=0||$namsx<=0||$sokim<=0||$tocdoin<=0||$dophangiai<=0||$tocdoin2<=0)
			{
				echo"<h1><b> :(</b><br>Giá trị phải là số nguyên dương và lớn hơn 0</h1>";
				return;
			}
			else
			{
				Class mayin
				{
					public $trongluong;
					public $namsx;
					public $hangsx;
					function nhap($trongluong,$namsx,$hangsx)
					{
						$this->trongluong=$trongluong;
						$this->namsx=$namsx;
						$this->hangsx=$hangsx;
					}
					public function xuat()
					{
					echo "Trọng lượng: ".$this->trongluong;
					echo "<br>Năm SX: ".$this->namsx;
					echo "<br>Hãng SX: ".$this->hangsx;
					}
				}
				Class mayinkim extends mayin
				{
					public $sokim;
					public $tocdoin;
					function nhap1($trongluong,$namsx,$hangsx,$sokim,$tocdoin)
					{
						$this->nhap($trongluong,$namsx,$hangsx);
						$this->sokim=$sokim;
						$this->tocdoin=$tocdoin;
					}
					public function xuat1()
					{
					  
							$this->xuat();
							echo "<br>Số kim: ".$this->sokim;
							echo "<br>Tốc độ in: ".$this->tocdoin." (trang/ phút)";
						
					}

				}
				Class mayinlaser extends mayin
				{

					public $dophangiai;
					public $tocdoin2;
					function nhap2($trongluong,$namsx,$hangsx,$dophangiai,$tocdoin2)
					{
						$this->nhap($trongluong,$namsx,$hangsx);
						$this->dophangiai=$dophangiai;
						$this->tocdoin2=$tocdoin2;
					}
					public function xuat2()
					{

							$this->xuat();
							echo "<br>Độ phân giải: ".$this->dophangiai;
							echo "<br>Tốc độ in: ".$this->tocdoin2." (trang/ phút)";
					}
				}
			echo "<br><h1><b>MÁY IN KIM</b></h1>";
			$mik = new mayinkim();
			$mik->nhap1($trongluong,$namsx,$hangsx,$sokim,$tocdoin);
			$mik->xuat1();
			echo "<br><h1><br><b>MÁY IN LASER</b></h1>";
			$mil= new mayinlaser();
			$mil->nhap2($trongluong,$namsx,$hangsx,$dophangiai,$tocdoin2);
			$mil->xuat2();
			}
		}
?>

</form>
</body>
</html>